package com.atguigu.mapreduce.demo.comparable;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @version V1.0
 * @author: guangcheng
 * @date: 2021/11/18 19:00
 * @description: 偏移量  一行内容  手机号  自定义输出
 */
public class PCounterMapper extends Mapper<LongWritable, Text, FlowBean, Text> {

    FlowBean outK = new FlowBean();
    Text outV = new Text();


    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String str = value.toString();
        String[] split = str.split("\t");

        outV.set(split[0]);

        outK.setUpFlow(Long.parseLong(split[1]));
        outK.setDownFlow(Long.parseLong(split[2]));
        outK.setSumFlow();

        context.write(outK, outV);
    }
}

